const mongoose = require('mongoose')

// 用户登录
const UserSchema = new mongoose.Schema({
  username: String,
  password: String,
  phone: Number
})

const UserModel = mongoose.model('user', UserSchema)

// 地址
const AdressSchema = new mongoose.Schema({
  id: Number,
  name: String,
  tel: Number,
  isDefault: Boolean,
  username: String,
  country: String,
  province: String,
  city: String,
  county: String,
  areaCode: String,
  postalCode: String,
  addressDetail: String
})

const UserAddress = mongoose.model('address', AdressSchema)

// 足迹
const FootPrint = new mongoose.Schema({
  commodity: Object,
  username: String
})

const UserFootPrint = mongoose.model('footprint', FootPrint)

// 收藏
const Collection = new mongoose.Schema({
  commodity: Object,
  username: String,
  id: Number
})

const UserCollection = mongoose.model('collection', Collection)

// 购物车
const Cart = new mongoose.Schema({
  username: String,
  cart: Array
})

const CartModel = mongoose.model('cart', Cart)

// 支付
const Apply = new mongoose.Schema({
  username: String,
  cart: Array,
  address: String,
  date: String,
  sure: Boolean,
  mon:String
})

const ApplyModel = mongoose.model('apply', Apply)

// 客服聊天记录
const Coustomer = new mongoose.Schema({
  username:String,
  records: Array
})

const CoustomerModel = mongoose.model('coustomer', Coustomer)

module.exports = {
  UserModel,
  UserAddress,
  UserFootPrint,
  UserCollection,
  CartModel,
  ApplyModel,
  CoustomerModel
}